home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / isc / parseint.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-09-17  |  2.0 KB  |  65 lines

  1. /*
  2.  * Copyright (C) 2004, 2005  Internet Systems Consortium, Inc. ("ISC")
  3.  * Copyright (C) 2001, 2002  Internet Software Consortium.
  4.  *
  5.  * Permission to use, copy, modify, and distribute this software for any
  6.  * purpose with or without fee is hereby granted, provided that the above
  7.  * copyright notice and this permission notice appear in all copies.
  8.  *
  9.  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10.  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11.  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12.  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13.  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14.  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15.  * PERFORMANCE OF THIS SOFTWARE.
  16.  */
  17.  
  18. /* $Id: parseint.h,v 1.3.18.2 2005/04/29 00:17:00 marka Exp $ */
  19.  
  20. #ifndef ISC_PARSEINT_H
  21. #define ISC_PARSEINT_H 1
  22.  
  23. #include <isc/lang.h>
  24. #include <isc/types.h>
  25.  
  26. /*! \file
  27.  * \brief Parse integers, in a saner way than atoi() or strtoul() do.
  28.  */
  29.  
  30. /***
  31.  ***    Functions
  32.  ***/
  33.  
  34. ISC_LANG_BEGINDECLS
  35.  
  36. isc_result_t
  37. isc_parse_uint32(isc_uint32_t *uip, const char *string, int base);
  38.  
  39. isc_result_t
  40. isc_parse_uint16(isc_uint16_t *uip, const char *string, int base);
  41.  
  42. isc_result_t
  43. isc_parse_uint8(isc_uint8_t *uip, const char *string, int base);
  44. /*%<
  45.  * Parse the null-terminated string 'string' containing a base 'base'
  46.  * integer, storing the result in '*uip'.  
  47.  * The base is interpreted
  48.  * as in strtoul().  Unlike strtoul(), leading whitespace, minus or
  49.  * plus signs are not accepted, and all errors (including overflow)
  50.  * are reported uniformly through the return value.
  51.  *
  52.  * Requires:
  53.  *\li    'string' points to a null-terminated string
  54.  *\li    0 <= 'base' <= 36
  55.  *
  56.  * Returns:
  57.  *\li    #ISC_R_SUCCESS
  58.  *\li    #ISC_R_BADNUMBER   The string is not numeric (in the given base)
  59.  *\li    #ISC_R_RANGE      The number is not representable as the requested type.
  60.  */
  61.  
  62. ISC_LANG_ENDDECLS
  63.  
  64. #endif /* ISC_PARSEINT_H */
  65.